package com.free.semantic.infrastruct.mapper;

import com.free.semantic.infrastruct.common.SemanticNetworkDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SemanticNetworkMapper {
    
    @Select("SELECT * FROM semantic_network WHERE id = #{id}")
    SemanticNetworkDO findById(@Param("id") Long id);
    
    @Select("SELECT * FROM semantic_network WHERE user_id = #{userId}")
    List<SemanticNetworkDO> findByUserId(@Param("userId") Long userId);
    
    @Select("SELECT * FROM semantic_network")
    List<SemanticNetworkDO> findAll();
    
    @Insert("INSERT INTO semantic_network(name, user_id, create_time, update_time) " +
            "VALUES(#{name}, #{userId}, NOW(), NOW())")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(SemanticNetworkDO semanticNetworkDO);
    
    @Update("UPDATE semantic_network SET name = #{name}, update_time = NOW() WHERE id = #{id}")
    int update(SemanticNetworkDO semanticNetworkDO);
    
    @Delete("DELETE FROM semantic_network WHERE id = #{id}")
    int deleteById(@Param("id") Long id);
} 